// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import router from './router'
import Header from './components/main/head.vue'
import Mainly from './components/blog/main.vue'
import Archives from './components/archives.vue'
import LeaveComments from './components/comment/leave_comments.vue'
import Link from './components/link.vue'
import About from './components/about/about.vue'
import AsideBy from './components/main/aside.vue'
import Foot from './components/main/foot.vue'
import Page from './components/blog/page.vue'
import BlogByCategory from './components/blog/blog_by_category.vue'

var {titleInit}  = require('../static/front-vue/js/showtip') ;


// 设置反向代理，前端请求默认发送到 http://localhost:84/api
//8443是tomcat打开SSL的文本服务的默认端口，默认配置文件里用的端口就是8443。默认的https端口号是443，因此tomcat为了区别使用了8443这个端口
var axios = require('axios')
axios.defaults.baseURL = '/api/api'
// 全局注册，之后可在其他组件中通过 this.$axios 发送数据
Vue.prototype.$axios = axios

Vue.config.productionTip = false

//vue中使用fontawesome
import { library } from '@fortawesome/fontawesome-svg-core'
import { fas } from '@fortawesome/free-solid-svg-icons'
import { far } from '@fortawesome/free-regular-svg-icons'
import { fab } from '@fortawesome/free-brands-svg-icons'
import { FontAwesomeIcon, FontAwesomeLayers, FontAwesomeLayersText }
 from '@fortawesome/vue-fontawesome'
 
library.add(fas, far, fab)
 
Vue.component('font-awesome-icon', FontAwesomeIcon)
Vue.component('font-awesome-layers', FontAwesomeLayers)
Vue.component('font-awesome-layers-text', FontAwesomeLayersText)


// 引入Element UI
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
Vue.use(ElementUI);

// 引入轮播图插件
import VueAwesomeSwiper from 'vue-awesome-swiper'
import 'swiper/dist/css/swiper.css'
Vue.use(VueAwesomeSwiper)


// 每次路由跳转返回最顶端
router.beforeEach((to, from, next) => {
  document.body.scrollTop = 0
  // firefox
  document.documentElement.scrollTop = 0
  // safari
  window.pageYOffset = 0
  next()
})

new Vue({
  el: '#app',
  router,
  components: { Header,Mainly,Archives,LeaveComments,Link,About,AsideBy,Foot,Page,BlogByCategory},  
  template: `<div>
  <Header/>
  <div class="container">   
    <keep-alive>
      <router-view></router-view>   
    </keep-alive>       
    <AsideBy/>
  </div>
  <Foot/>
</div>`
  
  
})
